home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1995 February: Tool Chest / Dev.CD Feb 95 / Dev.CD Feb 95.toast / Tool Chest / Development Tools & Languages / Dylan Related / Mindy-1.1 (sources only) / mindy-1.1 / demos / README < prev   
Encoding:
Text File  |  1994-06-29  |  3.8 KB  |  88 lines  |  [TEXT/ttxt]

  1.                              Mindy Demo Programs
  2.                              ===================
  3. ------------------------------------------------------------------------------
  4.  
  5. hello-world
  6. -----------
  7.   This is the canonical "hello, world" demo.  Type 
  8.  
  9.     mindy -f hello-world.dbc
  10.  
  11.   to run it.  
  12.  
  13. ------------------------------------------------------------------------------
  14.  
  15. cat
  16. ---
  17.   This program demonstrates the streams library by duplicating the UNIX (tm)
  18.   "cat" utility.  Usage is typical for a unix program.  It may be invoked
  19.   either with a set of files on the command line:  
  20.  
  21.     mindy -f cat.dbc file1 file2 ....
  22.  
  23.   or with no arguments, in which case it reads from "standard input".  You
  24.   may also specify special filename "-" which will refer to the standard
  25.   input.  
  26.  
  27.   On most Unix systems you should be able to make it into an executable
  28.   script by prepending the the line 
  29.  
  30.     #$INSTALL/bin/mindy -f
  31.  
  32.   to the compiled "dbc" file (and adding "execute" to the file's protection).
  33.   You could then simply type 
  34.  
  35.     cat.dbc file1 file2 ....
  36.  
  37.   You must, of course, remember to specify the MINDYPATH environment variable
  38.   so that it points to directories containing all of the relevant libraries.
  39.   (This demo uses only "dylan" and "streams", but the "html2txt" demo also
  40.   uses "collection-extensions".) 
  41.  
  42. ------------------------------------------------------------------------------
  43.  
  44. html2txt
  45. --------
  46.   The "html2txt" program is a filter which converts text in WWWs "HyperText
  47.   Markup Language" into simple formatted text.  Although it is a complete and
  48.   useful application, it is included in this distribution primarily as a
  49.   demonstration of a "real" (albeit small) Dylan (tm) program.  
  50.  
  51.   Usage is similar to "cat" above, except that it does not support the "-"
  52.   argument.  You may therefore set of files on the command line or use
  53.   standard input by specifying no command line arguments 
  54.  
  55.     mindy -f html2txt.dbc file1.html file2.html ....
  56.     mindy -f cat.dbc file1.html file2.html | mindy -f html2txt.dbc
  57.  
  58.   At present, "html2txt" accepts no command line switches, although the
  59.   behavior may be changed by changing several constant declarations towards
  60.   the top of the source file.  
  61.  
  62.   Useful test cases for this program are the files "demos.html", which was
  63.   used as the source for "README"; and
  64.   "$INSTALL/doc/collection-extensions.html", which was used as the source
  65.   file for the documentation file "$INSTALL/doc/collection-extensions.doc".  
  66.  
  67.   The basic translation strategy used by html2txt is to scan the file line by
  68.   line, looking for HTML "tags" and accumulating text that lies between any
  69.   two tags.  For each tag type, there is a set of routines (stored in tables)
  70.   which define the appropriate actions for starting and ending the
  71.   "environment" defined by the tag and for dumping the collected text from
  72.   within that environment as formatted text.  A basic control loop in
  73.   "process-HTML" is responsible for calling the appropriate tag actions.
  74.   This routine may be called recusively by some of the tag actions.  
  75.  
  76.   The "interface" between adjacent environments is handled via the "blank"
  77.   parameter which is passed around extensively.  This variable states whether
  78.   a blank line has just been printed.  Thus environments which believe that
  79.   they must be preceded or followed by a blank line can determine whetehr
  80.   they must do anything about it, and we lessen the risk that multiple
  81.   routines will emit blank lines when we only want a maximum of one.  
  82.  
  83.   The primary advantage of this organization is that it allows the
  84.   specialized actions for a single tag to be grouped together, and allows new
  85.   tags to be cleanly added.  It benefits greatly from Dylan's ability to
  86.   create anonymous methods and manipulate them as first class data objects,
  87.   as well as from the rich set of available collection types.  
  88.